#include<stdio.h>
#include<string.h>
#include<math.h>

#define MAX 300

double p[MAX][MAX];
double ratio[10][MAX][MAX];
double maxratio;
int n;
int winteam;

int main()
{
    int i,j;
    int matchround,position,team;
    
    while(1)
    {
        scanf("%d",&n);
        if(n==-1) break;
        
        memset(p,0,sizeof(p));
        memset(ratio,0,sizeof(ratio));
        
        for(i=0;i<1<<n;i++)
            for(j=0;j<1<<n;j++)
                scanf("%lf",&p[i][j]);
        
        //initialize ratio[][][]
        for(i=0;i<1<<n;i++)
                ratio[0][i][i]=1;
        
        //begin play
        for(matchround=0;matchround<n;matchround++)
        {
            for(position=0;position<1<<(n-matchround);position++)
            {
                for(team=0;team<1<<n;team++)
                {
                    if(ratio[matchround][position][team]==0)
                        continue;
                    
                    for(i=0;i<1<<n;i++) //Team [team] plays Team [i]
                     {
                        if(i==team)
                            continue;
                            
                        if(position%2==0)//host team
                            ratio[matchround+1][position/2][team]+=ratio[matchround][position][team]*ratio[matchround][position+1][i]*p[team][i];
                        else//guest team
                            ratio[matchround+1][position/2][team]+=ratio[matchround][position][team]*ratio[matchround][position-1][i]*p[team][i];
                        //printf("%d %d %d %lf\n",matchround+1,position/2,team,ratio[matchround+1][position/2][team]);
                    }           
                }    
            } 
        }
      
        
        //find the max ratio
        maxratio=0; winteam=-1;
        for(i=0;i<1<<n;i++)
        {
            //printf("%d %lf\n",i+1,ratio[n][0][i]);
            if(ratio[n][0][i]>maxratio)
            {
                maxratio=ratio[n][0][i]; winteam=i;
            } 
        }    
        
        winteam++;
        printf("%d\n",winteam);
        
        
        
    }   
    
    return 0;
}    
